<?php
include('databaseconnection.php');
/*$con = mysql_connect("localhost","root","");
if(!$con){
	echo "Unable to connect with server".mysql_error();
}
mysql_select_db("task",$con);*/
$resul = mysql_query("SELECT * FROM terms");
while($row = mysql_fetch_array($resul))
  {
  
  
  $a[]=$row['term'];
  
  }




	if(isset($_POST['phpname'])){
		$name=$_POST['phpname'];
		if(strlen($name)>0)
		{
			$hint="";
			for($i=0;$i<count($a);$i++)
			{
				if(strtolower($name)==strtolower(substr($a[$i],0,strlen($name))))
				{
					if($hint=="")
					{
						$hint=$a[$i];
					}
					else
					{
						$hint=$hint."</br>".$a[$i];
					}
				}
			}
			}
//set output to "no suggestion" if no hint were found
// or to the correct values	
		
	if($hint=="")
	{
		$response="no suggestion";
	}
	else
	{
		$response=$hint;
	}
		echo $response;
}
mysql_close($con);

?>